﻿//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------

using System;

namespace GameFramework.Resource
{
    /// <summary>
    /// 加载资源回调函数集。
    /// </summary>
    public sealed class LoadAssetCallbacks
    {

        /// <summary>
        /// 初始化加载资源回调函数集的新实例。
        /// </summary>
        /// <param name="loadAssetSuccessCallback">加载资源成功回调函数。</param>
        public LoadAssetCallbacks(Action<string, object, float, object> loadAssetSuccessCallback)
            : this(loadAssetSuccessCallback, null, null, null)
        {
        }

        /// <summary>
        /// 初始化加载资源回调函数集的新实例。
        /// </summary>
        /// <param name="loadAssetSuccessCallback">加载资源成功回调函数。</param>
        /// <param name="loadAssetFailureCallback">加载资源失败回调函数。</param>
        public LoadAssetCallbacks(
            Action<string, object, float, object> loadAssetSuccessCallback,
            Action<string, LoadResourceStatus, string, object> loadAssetFailureCallback)
            : this(loadAssetSuccessCallback, loadAssetFailureCallback, null, null)
        {
        }
        /// <summary>
        /// 初始化加载资源回调函数集的新实例。
        /// </summary>
        /// <param name="loadAssetSuccessCallback">加载资源成功回调函数。</param>
        /// <param name="loadAssetFailureCallback">加载资源失败回调函数。</param>
        /// <param name="loadAssetUpdateCallback">加载资源更新回调函数。</param>
        /// <param name="loadAssetDependencyAssetCallback">加载资源时加载依赖资源回调函数。</param>
        public LoadAssetCallbacks(
            Action<string, object, float, object> loadAssetSuccessCallback,
            Action<string, LoadResourceStatus, string, object> loadAssetFailureCallback,
            Action<string, float, object> loadAssetUpdateCallback,
            Action<string, string, int, int, object> loadAssetDependencyAssetCallback)
        {
            if (loadAssetSuccessCallback == null)
            {
                throw new GeneralException("Load asset success callback is invalid.");
            }

            LoadAssetSuccessCallback = loadAssetSuccessCallback;
            LoadAssetFailureCallback = loadAssetFailureCallback;
            LoadAssetUpdateCallback = loadAssetUpdateCallback;
            LoadAssetDependencyAssetCallback = loadAssetDependencyAssetCallback;
        }

        /// <summary>
        /// 获取加载资源成功回调函数。
        /// </summary>
        public Action<string, object, float, object> LoadAssetSuccessCallback { get; }

        /// <summary>
        /// 获取加载资源失败回调函数。
        /// </summary>
        public Action<string, LoadResourceStatus, string, object> LoadAssetFailureCallback { get; }

        /// <summary>
        /// 获取加载资源更新回调函数。
        /// </summary>
        public Action<string, float, object> LoadAssetUpdateCallback { get; }

        /// <summary>
        /// 获取加载资源时加载依赖资源回调函数。
        /// </summary>
        public Action<string, string, int, int, object> LoadAssetDependencyAssetCallback { get; }
    }
}
